package com.google.code.avajhelpdesk.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity(name = "issue")
public class Issue extends BasicEntity {

	public static enum IssueStatus {
		OPEN, 
		CLOSED, 
		REOPEN, 
		FIXED, 
		CHECKED_NOT_ISSUE,
		NEED_INFO
	}
	
	public static enum IssuePriority {
		VERY_LOW,
		LOW, 
		NORMAL, 
		HIGH,
		HIGHEST
	}
	
	private static final long serialVersionUID = 1L;

	@Column(length = 512, nullable = false)
	private String title;
	
	@Column(length = 4096)
	private String description;
	
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="user_id")
	private User owner;
	
	@Column(name="creation_time")
	@Temporal(TemporalType.DATE)
	private Date creationTime;
	
	@Column(name="closing_time")
	@Temporal(TemporalType.DATE)
	private Date closingTime;
	
	@Enumerated(EnumType.STRING)
	private IssuePriority priority;

	@Enumerated(EnumType.STRING)
	private IssueStatus status;
	
	public Issue() {
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setPriority(IssuePriority priority) {
		this.priority = priority;
	}
	
	public IssuePriority getPriority() {
		return priority;
	}
	
	public void setOwner(User owner) {
		this.owner = owner;
	}
	
	public User getOwner() {
		return owner;
	}
}
